import { createApp, h } from 'vue'
import { createRouter, createWebHashHistory } from 'vue-router'
import hljs from 'highlight.js/lib/core'
import javascript from 'highlight.js/lib/languages/javascript'
import json from 'highlight.js/lib/languages/json'
import xml from 'highlight.js/lib/languages/xml'
import plaintext from 'highlight.js/lib/languages/plaintext'
import 'highlight.js/styles/github.css'

import App from './App.vue'
import Dashboard from './pages/Dashboard.vue'
import Tasks from './pages/Tasks.vue'
import DLQ from './pages/DLQ.vue'
import Settings from './pages/Settings.vue'

// 注册语言
hljs.registerLanguage('javascript', javascript)
hljs.registerLanguage('json', json)
hljs.registerLanguage('xml', xml)
hljs.registerLanguage('plaintext', plaintext)
hljs.registerLanguage('text', plaintext)

// 设置全局hljs - 确保在DOM加载前设置
if (typeof window !== 'undefined') {
  window.hljs = hljs
}

const router = createRouter({
  history: createWebHashHistory(),
  routes: [
    { path: '/', component: Dashboard },
    { path: '/tasks', component: Tasks },
    { path: '/dlq', component: DLQ },
    { path: '/settings', component: Settings },
  ]
})

const app = createApp(App)
app.config.globalProperties.$hljs = hljs
app.use(router).mount('#app')

